<?php
class StudentsJob extends AppModel {

    public $name = 'StudentsJob';
    public $validate = array(
        'student_id' => array('numeric'),
        'job_id' => array('numeric')
    );

    //The Associations below have been created with all possible keys,
    // those that are not needed can be removed
    public $belongsTo = array(
        'Student' => array(
            'className' => 'Student',
            'foreignKey' => 'student_id',
            'counterCache' => true,
            'conditions' => '',
            'fields' => '',
            'order' => ''
        ),
        'Job' => array(
            'className' => 'Job',
            'foreignKey' => 'job_id',
            'counterCache' => true,
            'conditions' => '',
            'fields' => '',
            'order' => ''
        )
    );

     public function check($data){
         if(empty($data['student_id']) || empty($data['job_id'])){
             return false;
         }else{
            return $this->find('count', array(
                'conditions'=>array(
                    'StudentsJob.student_id' => $data['student_id'],
                    'StudentsJob.job_id' => $data['job_id']
                )
            ));
         }
     }

}
?>